<template>
  <div @click="$router.push('/article/' + item.art_id)">
    <!-- <div @click="$router.push('/article?id=' + item.art_id)"> -->
    <!-- <div @click="$router.push({ path: '/article', query: { id: item.art_id } })"> -->
    <div class="article-item van-hairline--bottom" v-if="item.cover.type === 0">
      <p class="title van-multi-ellipsis--l2">
        {{ item.title }}
      </p>
      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}评论</span>
        <span>{{ item.pubdate | filterTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>

    <div
      class="article-item van-hairline--bottom"
      v-else-if="item.cover.type === 1"
    >
      <p class="title van-multi-ellipsis--l2 w66">
        {{ item.title }}
      </p>
      <img class="img" :src="item.cover.images[0]" alt="" />
      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}评论</span>
        <span>{{ item.pubdate | filterTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>

    <div class="article-item van-hairline--bottom" v-else>
      <p class="title van-multi-ellipsis--l2">
        {{ item.title }}
      </p>
      <img
        v-for="(i, index) in item.cover.images"
        :key="index"
        class="img"
        :src="i"
        alt=""
      />

      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}评论</span>
        <span>{{ item.pubdate | filterTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'ArticleItem',
  props: ['item']
}
</script>
<style scoped lang="less">
.article-item {
  padding: 15px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .title {
    width: 100%;
    margin: 0;
    line-height: 22px;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    max-height: 44px;
    &.w66 {
      width: 66%;
    }
  }
  .img {
    width: 112px;
    height: 74px;
    border-radius: 4px;
    margin-bottom: 8px;
  }
  .info {
    width: 100%;
    color: #a5a6ab;
    font-size: 12px;
    position: relative;
    span {
      margin-right: 12px;
    }
    .geek-icon {
      float: right;
      font-size: 14px;
    }
  }
}
</style>
